#include <stdio.h>
#include <stdlib.h>
#include "Structs.h"
#include "Pong3D.h"
#include <GL/glut.h>
#include <math.h>
#include <Windows.h>


void getAIPaddlePosition(GLfloat newPosition[], GLfloat paddleX, GLfloat paddleY, GLfloat paddleZ, 
								GLfloat ballX, GLfloat ballY, GLfloat ballZ, 
								GLfloat maxSpeed, GLfloat tolerance)
{
	int i,j;
	GLfloat oldPosition[3] = {paddleX,paddleY,paddleZ};
	GLfloat ballPos[3] = {ballX,ballY,ballZ};
	GLfloat deltas[3] = {ballX - paddleX, ballY - paddleY, ballZ - paddleZ};

	newPosition[2] = paddleZ;  //We dont ever change Z position for this AI

	//Dont want to add to the z value, so only do till 2
	for ( i = 0; i < 2; i++)
	{
		if ( deltas[i] > 0){
			//Update paddle position
			newPosition[i] = oldPosition[i] + maxSpeed;
		}else if(deltas[i] < 0){
			newPosition[i] = oldPosition[i] - maxSpeed;
		}
	}
}
